% Sheperd plot from our timing data
% Takes a 2D array of times, 1 subject per row; each row is generated by 
% plotShepard(...);
% Generates a plot like Sheperd and Metzler and includes SEM.

function means = plotShepardMultipleSubjects(subject_times)

for group = 1:size(subject_times,2)
    [means(group) sems(group)]=grpstats( subject_times(:,group),[],{'mean', 'sem'});
end

x=[0 90 180 270]
means
errorbar( x,means,sems,'ok','LineWidth',1.1)

[b,BINT,R,RINT,STATS]=regress(means',[ones(size(x')) x']);

disp(['R^2:' num2str(STATS(1))]);
disp(['p:' num2str(STATS(3))]);

hold on
plot(x,b(1)+x*b(2),'k','LineWidth',1.1)
hold off;

xlabel('Angular difference (degrees)','FontSize',16)
ylabel('Response time (ms)','FontSize',16)
set(gca, 'XTick', [0, 30, 60, 90, 120, 150, 180, 210, 240, 270, 300],'FontSize',14);
axis([-30 300 0 1800])
colormap(gray)
